/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.wx.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.wx.entity.WxActivityShare;
import com.jeesite.modules.wx.service.WxActivityShareService;

/**
 * wx_activity_shareController
 * @author wangjianxin
 * @version 2018-09-28
 */
@Controller
@RequestMapping(value = "${adminPath}/wx/wxActivityShare")
public class WxActivityShareController extends BaseController {

	@Autowired
	private WxActivityShareService wxActivityShareService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public WxActivityShare get(String id, boolean isNewRecord) {
		return wxActivityShareService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("wx:wxActivityShare:view")
	@RequestMapping(value = {"list", ""})
	public String list(WxActivityShare wxActivityShare, Model model) {
		model.addAttribute("wxActivityShare", wxActivityShare);
		return "modules/wx/wxActivityShareList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("wx:wxActivityShare:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<WxActivityShare> listData(WxActivityShare wxActivityShare, HttpServletRequest request, HttpServletResponse response) {
		Page<WxActivityShare> page = wxActivityShareService.findPage(new Page<WxActivityShare>(request, response), wxActivityShare); 
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("wx:wxActivityShare:view")
	@RequestMapping(value = "form")
	public String form(WxActivityShare wxActivityShare, Model model) {
		model.addAttribute("wxActivityShare", wxActivityShare);
		return "modules/wx/wxActivityShareForm";
	}

	/**
	 * 保存wx_activity_share
	 */
	@RequiresPermissions("wx:wxActivityShare:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated WxActivityShare wxActivityShare) {
		wxActivityShareService.save(wxActivityShare);
		return renderResult(Global.TRUE, text("保存wx_activity_share成功！"));
	}
	
	/**
	 * 删除wx_activity_share
	 */
	@RequiresPermissions("wx:wxActivityShare:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(WxActivityShare wxActivityShare) {
		wxActivityShareService.delete(wxActivityShare);
		return renderResult(Global.TRUE, text("删除wx_activity_share成功！"));
	}
	
}